package com.ruoyi.exam.domain.vo;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 试题导入VO类
 */
public class QuestionImportVo extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** 题型 */
    @Excel(name = "题型", type = Excel.Type.IMPORT)
    private String questionTypeName;

    /** 题干 */
    @Excel(name = "题干", type = Excel.Type.IMPORT)
    private String questionTitle;

    /** 选项，格式：A-选项内容|B-选项内容|C-选项内容|D-选项内容 */
    @Excel(name = "选项", type = Excel.Type.IMPORT)
    private String options;

    /** 答案 */
    @Excel(name = "答案", type = Excel.Type.IMPORT)
    private String answer;

    /** 题目依据 */
    @Excel(name = "题目依据", type = Excel.Type.IMPORT)
    private String questionAnswerExplain;

    /** 试题分数 */
    @Excel(name = "试题分数", type = Excel.Type.IMPORT)
    private Double questionScore;

    // getter和setter方法
    public String getQuestionTypeName() {
        return questionTypeName;
    }

    public void setQuestionTypeName(String questionTypeName) {
        this.questionTypeName = trimToNull(questionTypeName);
    }

    public String getQuestionTitle() {
        return questionTitle;
    }

    public void setQuestionTitle(String questionTitle) {
        this.questionTitle = trimToNull(questionTitle);
    }

    public String getOptions() {
        return options;
    }

    public void setOptions(String options) {
        this.options = trimToNull(options);
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = trimToNull(answer);
    }

    public String getQuestionAnswerExplain() {
        return questionAnswerExplain;
    }

    public void setQuestionAnswerExplain(String questionAnswerExplain) {
        this.questionAnswerExplain = trimToNull(questionAnswerExplain);
    }

    public Double getQuestionScore() {
        return questionScore;
    }

    public void setQuestionScore(Double questionScore) {
        this.questionScore = questionScore;
    }

    /**
     * 去除字符串首尾空白字符（包括不可见字符），如果结果为空则返回null
     */
    private String trimToNull(String str) {
        if (str == null) {
            return null;
        }
        // 去除所有不可见字符，包括空格、制表符、换行符、回车符等
        String trimmed = str.replaceAll("^[\\s\\u00A0\\u2000-\\u200F\\u2028-\\u202F]+|[\\s\\u00A0\\u2000-\\u200F\\u2028-\\u202F]+$", "");
        return trimmed.isEmpty() ? null : trimmed;
    }
}